/*
 * @Description: 根据节点生成对应的html标签
 */
// import { escapeXml } from "../funs";
export class HtmlGenerate {

  createTag_ (tagName, selfClosing) {
    let buffer = `<${tagName}`;
    if (selfClosing) {
      buffer += ' /';
    }
    buffer += '>';
    return buffer;
  }

  emph (buffer, mnode, close) {
    if (close) {
      buffer += this.createTag_('/em');
    } else {
      buffer += this.createTag_('em');
    }
    return buffer;
  }


  paragraph (buffer, mnode, close) {
    if (mnode.isShow) {
      if (close) {
        buffer += this.createTag_('/p');
      } else {
        buffer += this.createTag_('p');
      }
    }
    return buffer;
  }
  strong (buffer, mnode, close) {
    if (close) {
      buffer += this.createTag_('/strong');
    } else {
      buffer += this.createTag_('strong');
    }
    return buffer;
  }

  text (buffer, mnode, close) {
    if (mnode.marker) {
    //   buffer += this.createTag_('span') + escapeXml(mnode.text);
      buffer += this.createTag_('span') + mnode.text;
      buffer += this.createTag_('/span');
    } else {
      buffer += mnode.text;
    }
    return buffer
  }

  del (buffer, mnode, close) {
    if (close) {
      buffer += this.createTag_('/del');
    } else {
      buffer += this.createTag_('del');
    }
    return buffer;
  }
  code (buffer, mnode, close) {
    if (close) {
      buffer += this.createTag_('/code');
    } else {
      buffer += this.createTag_('code');
    }
    return buffer;
  }

}
export default HtmlGenerate;